import Vue from 'vue'
import Router from 'vue-router'
import workDetail from '@/views/work/workDetail'
Vue.use(Router)
import Layout from '@/layout'
import { errorLog } from '@/settings'
export const constantRoutes = [
  {
    path: '/',
    redirect: '/departmentList/list'
  },
  {
    path: '/view',
    component: () => import('@/views/view/index'),
    hidden: true,
    name: 'view',
    meta: { title: '数智化工作台', keepAlive: true }
  },
  {
    path: '/userList',
    component: () => import('@/views/work/userList'),
    hidden: true,
    name: 'userList',
    meta: { title: '用户管理', icon: 'el-icon-s-tools' }
  },
  {
    path: '/projectTable',
    component: () => import('@/views/tableList/projectTable'),
    hidden: true,
    name: '项目情况列表',
    meta: { title: '项目情况列表' }
  },
  {
    path: '/warnTable',
    component: () => import('@/views/tableList/warnTable'),
    hidden: true,
    name: '政务外网商机预警',
    meta: { title: '政务外网商机预警' }
  },
  {
    path: '/warnTableCloud',
    component: () => import('@/views/tableList/warnTableCloud'),
    hidden: true,
    name: '政务云商机预警',
    meta: { title: '政务云商机预警' }
  },
  {
    path: '/dqytList',
    component: () => import('@/views/tableList/dqytList'),
    hidden: true,
    name: '特色客户商机清单',
    meta: { title: '特色客户商机清单' }
  }, {
    path: '/governmentTable',
    component: () => import('@/views/tableList/governmentTable'),
    hidden: true,
    name: '数字政府',
    meta: { title: '数字政府' }
  },
  {
    path: '/customerList',
    component: () => import('@/views/tableList/customerList'),
    hidden: true,
    name: '政务外网客户清单',
    meta: { title: '政务外网客户清单' }
  },
  {
    path: '/customerListCloud',
    component: () => import('@/views/tableList/customerListCloud'),
    hidden: true,
    name: '政务云客户清单',
    meta: { title: '政务云客户清单' }
  },
  {
    path: '/businessOpportunitiesList',
    component: () => import('@/views/tableList/businessOpportunitiesList'),
    hidden: true,
    name: '政务外网商机清单',
    meta: { title: '政务外网商机清单' }
  },
  {
    path: '/businessOpportunitiesListCloud',
    component: () => import('@/views/tableList/businessOpportunitiesListCloud'),
    hidden: true,
    name: '政务云商机清单',
    meta: { title: '政务云商机清单' }
  },
  {
    path: '/mgrThreeTable',
    component: () => import('@/views/tableList/mgrThreeTable'),
    hidden: true,
    name: '300万以上项目情况列表',
    meta: { title: '300万以上项目情况列表' }
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/tokenLogin',
    component: () => import('@/views/login/tokenLogin'),
    hidden: true,
    name: 'tokenLogin',
    meta: { title: '登录' }
  },
  {
    path: '/departmentList',
    component: Layout,
    children: [
      {
        path: 'list',
        component: () => import('@/views/work/departmentList'),
        name: 'mytask',
        meta: { title: '部门OKR', icon: 'el-icon-s-cooperation', affix: true }
      }
    ]
  },
  {
    path: '/work',
    component: Layout,
    children: [
      {
        path: 'list',
        component: () => import('@/views/work/list'),
        name: 'work',
        meta: { title: '科室OKR', icon: 'el-icon-s-claim' }
      },
      {
        path: 'detail/:id',
        component: workDetail,
        name: 'workDetail',
        meta: { title: '目标详情' },
        hidden: true,
      }
    ]
  },
  {
    path: '/mytask',
    component: Layout,
    children: [
      {
        path: 'list',
        component: () => import('@/views/work/mytask'),
        name: 'mytask',
        meta: { title: 'OKR待办', icon: 'el-icon-s-opportunity' }
      }
    ]
  },
  {
    path: '/workList',
    component: Layout,
    children: [
      {
        path: 'list',
        component: () => import('@/views/work/workList'),
        name: 'workList',
        meta: { title: 'OKR清单', icon: 'el-icon-s-management' }
      }
    ]
  },
  {
    path: '/workListNew',
    component: Layout,
    children: [
      {
        path: 'list',
        component: () => import('@/views/work/workListNew'),
        name: 'workListNew',
        meta: { title: 'OKR清单(新)', icon: 'el-icon-s-management', noCache: true },
        // hidden: true
      }
    ]
  },
  {
    path: '/supervisionImplementation',
    component: Layout,
    redirect: '/supervisionImplementation/list',
    meta: { title: '督办清单', icon: 'el-icon-star-on' },
    children: [
      {
        path: 'list',
        component: () => import('@/views/work/supervisionImplementation'),
        name: 'supervisionImplementation',
        meta: { title: '督办派发' }
      },
      // {
      //   path: 'supervisionCard',
      //   component: () => import('@/views/work/supervisionCard'),
      //   name: 'supervisionCard',
      //   meta: { title: '督办待办' }
      // },
      {
        path: 'supervisionImplementationList',
        component: () => import('@/views/work/supervisionImplementationList'),
        name: 'supervisionImplementationList',
        meta: { title: '督办清单' }
      },
      {
        path: 'supervisionImplementationListNew',
        component: () => import('@/views/work/supervisionImplementationListNew'),
        name: 'supervisionImplementationListNew',
        // hidden: true,
        meta: { title: '督办清单(新)', noCache: true }
      }
    ]
  },
  {
    path: '/leaderAssignedList',
    component: Layout,
    children: [
      {
        path: 'list',
        component: () => import('@/views/work/leaderAssignedList'),
        name: 'leaderAssignedList',
        meta: { title: '领导交办', icon: 'el-icon-s-custom' }
      }
    ]
  },
  {
    path: '/network',
    component: Layout,
    redirect: '/network/customerList',
    meta: { title: '政务外网调度', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'customerList',
        component: () => import('@/views/tableList/customerList'),
        name: 'customerList',
        meta: { title: '客户清单' }
      },
      {
        path: 'businessOpportunitiesList',
        component: () => import('@/views/tableList/businessOpportunitiesList'),
        name: 'businessOpportunitiesList',
        meta: { title: '商机清单' }
      },
      {
        path: 'warnTable',
        component: () => import('@/views/tableList/warnTable'),
        name: 'warnTable',
        meta: { title: '商机预警' }
      },
      {
        path: 'list',
        component: () => import('@/views/work/network'),
        name: 'network',
        meta: { title: '调度指标派发' }
      },
      {
        path: 'netTask',
        component: () => import('@/views/work/netTask'),
        name: 'netTask',
        meta: { title: '调度指标待办' }
      },
      {
        path: 'cloudDetail/:id',
        component: () => import('@/views/work/cloudDetail'),
        name: 'cloudDetail',
        meta: { title: '目标详情' },
        hidden: true,
      }
    ]
  },
  {
    path: '/cloudwork',
    component: Layout,
    redirect: '/cloudwork/customerList',
    meta: { title: '政务云调度', icon: 'el-icon-upload', noCache: false },
    children: [
      {
        path: 'customerListCloud',
        component: () => import('@/views/tableList/customerListCloud'),
        name: 'customerListCloud',
        meta: { title: '客户清单', noCache: false }
      },
      {
        path: 'businessOpportunitiesListCloud',
        component: () => import('@/views/tableList/businessOpportunitiesListCloud'),
        name: 'businessOpportunitiesListCloud',
        meta: { title: '商机清单', noCache: false }
      },
      {
        path: 'warnTableCloud',
        component: () => import('@/views/tableList/warnTableCloud'),
        name: 'warnTableCloud',
        meta: { title: '商机预警', noCache: false }
      },
      {
        path: 'list',
        component: () => import('@/views/work/cloudwork'),
        name: 'cloudwork',
        meta: { title: '调度指标派发', noCache: false }
      },
      {
        path: 'netTask',
        component: () => import('@/views/work/netTask'),
        name: 'network',
        meta: { title: '调度指标待办', noCache: false }
      },
      {
        path: 'cloudDetail/:id',
        component: () => import('@/views/work/cloudDetail'),
        name: 'cloudDetail',
        meta: { title: '目标详情' },
        hidden: true,
      }
    ]
  },
  {
    path: '/featuredClients',
    component: Layout,
    redirect: '/featuredClients/dqytList',
    meta: { title: '特色客户商机调度', icon: 'el-icon-s-flag' },
    children: [
      {
        path: 'dqytList',
        component: () => import('@/views/tableList/dqytList'),
        name: 'dqytList',
        meta: { title: '大庆油田商机清单' },
      }
    ]
  },
  {
    path: '/superviseList',
    component: Layout,
    redirect: '/superviseList/list',
    meta: { title: '地市调度', icon: 'el-icon-message-solid' },
    children: [
      {
        path: 'list',
        component: () => import('@/views/work/superviseList'),
        name: 'superviseListSend',
        meta: { title: '调度派发' }
      },
      {
        path: 'supervisetask',
        component: () => import('@/views/work/supervisetask'),
        name: 'superviseList',
        meta: { title: '调度待办' }
      }
    ]
  },
  {
    path: '/weeklyReport',
    component: Layout,
    redirect: '/weeklyReport/list',
    meta: { title: '重点项目进展', icon: 'el-icon-s-order' },
    children: [
      {
        path: 'list',
        component: () => import('@/views/work/weeklyReport'),
        name: 'weeklyReport',
        meta: { title: '重点项目进展' }
      },
      {
        path: 'ganttDetail/:id',
        component: () => import('@/views/work/Gantt'),
        name: 'gantt',
        meta: { title: '重点项目进展详情' },
        hidden: true,
      }
    ]
  },
  {
    path: '/myOkr',
    component: Layout,
    children: [
      {
        path: 'list',
        component: () => import('@/views/work/myOkr'),
        name: 'myOkr',
        meta: { title: '我的OKR', icon: 'el-icon-user-solid' }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    meta: { title: '用户管理', icon: 'el-icon-s-tools' },
    children: [
      {
        path: 'userList',
        component: () => import('@/views/work/userList'),
        name: 'userList',
        meta: { title: '用户管理', icon: 'el-icon-s-tools' }
      }
    ]
  },
  {
    path: '/userPdf',
    component: Layout,
    children: [
      {
        path: 'pdf',
        component: () => import('@/views/userPdf/pdf'),
        name: 'pdf',
        meta: { title: '用户手册', icon: 'el-icon-info' }
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}
export default router

